﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AbcCorp.BLO;
using AbcCorp.DTO;

namespace AbcCorp.ProductService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IProductService
    {
        [FaultContract(typeof(Product))]
        [OperationContract]
        bool AddProduct(Product newProduct);

        [FaultContract(typeof(Product))]
        [OperationContract]
        bool UpdateProduct(Product newInfo, int id);

        [FaultContract(typeof(Product))]
        [OperationContract]
        bool DeleteProduct(int prodid);

        [FaultContract(typeof(Product))]
        [OperationContract]
        IList<Product> GetProducts();

        [FaultContract(typeof(Product))]
        [OperationContract]
        Product GetProduct(int productid);

        [FaultContract(typeof(Product))]
        [OperationContract]
        IList<Product> GetProductByCategory(int catid);

        [FaultContract(typeof(Product))]
        [OperationContract]
        IList<Product> FindProduct(string keySearch, int catid);
    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations
    [DataContract]
    public class Product
    {
        #region Properties

        /// <summary>
        /// Mã sản phẩm
        /// </summary>
        [DataMember]
        public int ProductID { get; set; }

        /// <summary>
        /// Tên sản phẩm
        /// </summary>
        [DataMember]
        public string ProductName { get; set; }

        /// <summary>
        /// Giá 
        /// </summary>
        [DataMember]
        public decimal Price { get; set; }

        /// <summary>
        /// Số phần trăm giảm giá
        /// </summary>
        [DataMember]
        public int Discount { get; set; }

        /// <summary>
        /// Xuất sứ 
        /// </summary>
        [DataMember]
        public string Origin { get; set; }

        /// <summary>
        /// Số lượng 
        /// </summary>
        [DataMember]
        public int Quantity { get; set; }

        /// <summary>
        /// Hình ảnh 
        /// </summary>
        [DataMember]
        public string ProductImage { get; set; }

        /// <summary>
        /// Thời gian bảo hành
        /// </summary>
        [DataMember]
        public short GuaranteePeriod { get; set; }

        [DataMember]
        public int CategoryID  { get; set; }
        #endregion
    }
}
